<template>
	<view class="box">
		<radio-group>
			<view class="item publc" v-for="(item, index) in getlist" :key="item.id"
				@click="changeaddress(index,item.id)">
				<view class="i1">
					<label class="uni-list-cell uni-list-cell-pd">
						<view>
							<radio color="#F5AC4F" :value="item.id" :checked="addclass == index ? true : false" />
						</view>
					</label>
					<view class="left">
						<view class="c1">
							<view class="moren" v-if="item.is_default == 1">默认</view>
							<view class="name">{{ item.connect_name }}</view>
							<view class="shopName">（{{ item.store }})</view>
						</view>
						<view class="addressMargin">{{ item.province_name }} {{ item.city_name }} {{ item.area_name }}
							{{ item.detail_address }}
						</view>
						<view class="">手机号：{{ item.connect_mobile }}</view>
					</view>
				</view>
				<view class="right" @click.stop="onlcick(1,item)">
					<uni-icons type="compose" size="30"></uni-icons>
				</view>
			</view>

			<view class="btnBox" @click="addGetAddress(2)">
				<view class="btn">+添加收货地址</view>
			</view>
		</radio-group>
	</view>
</template>

<script>
	const httpRequest = require("@/commonFun/httpRequest.js");
	import conmon from '@/commonFun/conmon.js';
	export default {
		data() {
			return {
				current: '1',
				getlist: [],
				addressback: '',
				addclass: '',
			};
		},
		onLoad(options) {
			if (options) {
				console.log(options);
				this.addressback = options.address
			}
		},
		onShow() {
			this.maddress();
		},
		methods: {
			changeaddress(index, id) {
				if (this.addressback == 1) {
					this.addclass = index;
					// item.is_default = 1;
					uni.$emit('address', id);
					uni.navigateBack(1);
				}
			},
			maddress() {
				let _this = this
				httpRequest.request('/appapi/applet/address/getlist', 'POST', {}).then(res => {
					_this.getlist = res.data.list
				})
			},
			onlcick(i, v) {
				let obj = {
					value: i,
					item: v
				}
				uni.navigateTo({
					url: "addGetAddress?msg=" + encodeURIComponent(JSON.stringify(obj))
				});
			},
			addGetAddress(i) {
				let obj = {
					value: i,
					item: ""
				}
				uni.navigateTo({
					url: "addGetAddress?msg=" + encodeURIComponent(JSON.stringify(obj))
				});
			},
		}
	};
</script>

<style scoped lang="scss">
	.publc:last-child {
		background-color: #e34e33 !important;
	}

	.box {
		padding: 20rpx 20rpx 160rpx 20rpx;

		.btnBox {
			background-color: rgb(245, 245, 245);
			position: fixed;
			bottom: 0;
			z-index: 10;
			padding: 20rpx 0 40rpx 0;
		}

		.btn {
			background-color: #f5ac4f;
			color: #ffffff;
			border-radius: 20px;
			padding: 30rpx 0;
			text-align: center;
			// position: fixed;
			// bottom: 40rpx;
			font-size: 32rpx;
			width: 95vw;
		}

		.item {
			padding: 20rpx;
			background-color: #ffffff;
			border-radius: 8px;
			display: flex;
			align-items: center;
			font-size: 32rpx;
			color: #999999;
			margin-bottom: 20rpx;
			justify-content: space-between;

			.i1 {
				display: flex;
				align-items: center;

				.left {
					flex-direction: column;
					display: flex;
					justify-content: space-between;
					margin-left: 20rpx;

					.c1 {
						display: flex;

						.moren {
							padding: 8rpx 10rpx;
							background-color: #999999;
							border-radius: 20px;
							color: #ffffff;
							line-height: 28rpx;
						}

						.name {
							color: #333333;
							margin: 0 10rpx;
						}
					}
				}
			}
		}
	}

	.addressMargin {
		margin: 40rpx 0;
	}
</style>
